package com.acwing.partition20;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/21 20:10
 */
public class AC1904奶牛慢跑 {

    private static final int N = (int) (1e5 + 10), INF = (int) 2e9;
    private static int n = 0;
    private static int[] v = new int[N];

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        for (int i = 0; i < n; i++) {
            String[] s = reader.readLine().split("\\s+");
            v[i] = Integer.parseInt(s[1]);
        }
        int answer = 0, velMin = INF;
        for (int i = n - 1; i >= 0; i--) {
            if (v[i] <= velMin) {
                answer++;
                velMin = v[i];
            }
        }
        writer.write(answer + "\n");
        writer.flush();
    }
}
